import axios from 'axios';

const service=axios.create({
	baseURL:'http://47.99.124.245:8009',
	timeout: 5000
});
service.interceptors.request.use(
	//此处进行token等数据处理
    config => {
		if (localStorage.getItem('token')) {
			config.headers.token = localStorage.getItem('token');
		}
        return config;
    },
	// Do something with request error
    error => {
        console.log(error);
        return Promise.reject();
    }
);

service.interceptors.response.use(
    response => {
        if (response.status === 200) {
            return response.data;
        } else {
            Promise.reject();
        }
    },
    error => {
        console.log(error);
        return Promise.reject();
    }
);


export default service;
